@prefix: ~'swiper';

@duaring: 0.6s;

.show() {
  opacity: 1;
  transition: all @duaring;
}

@keyframes spanScale {
  0% {
    transform: translateX(-50%) translateZ(0) scale(1.2);
  }
  50% {
    transform: translateX(-50%) translateZ(0) scale(1.1);
  }
  100% {
    transform: translateX(-50%) translateZ(0) scale(1.2);
  }
}

.prevActiveFn(@position: 50%) {
  @keyframes prevActive {
    0% {
      left: @position;
    }
    100% {
      left: 0;
    }
  }

  animation: prevActive @duaring;
}

.nextActiveFn(@position: 50%) {
  @keyframes nextActive {
    0% {
      right: @position;
    }
    100% {
      right: 0;
    }
  }

  animation: nextActive @duaring;
}

@radius: 8px;

.@{prefix} {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
  height: 100%;
  margin: 20px 0;
  &-container {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    height: calc(90% - 20px);
    &-title {
      position: absolute;
      right: 6px;
      bottom: 6px;
      padding: 2px 10px;
      font-size: 12px;
      font-style: normal;
      color: white;
      background-color: var(--base-color);
      border-radius: 2px;
      transform: translateZ(0);
      backface-visibility: hidden;
    }
    &-left,
    &-right {
      position: absolute;
      top: 0;
      z-index: 2;
      display: flex;
      align-items: center;
      justify-content: center;
      width: 80px;
      height: 100%;
      cursor: pointer;
      opacity: 0;
      transition: opacity 0.2s;
    }
    &-left {
      left: 0;
      background-image: linear-gradient(to right, #000000bf, transparent);
      border-top-left-radius: @radius;
      border-bottom-left-radius: @radius;
    }
    &-right {
      right: 0;
      background-image: linear-gradient(to left, #000000bf, transparent);
      border-top-right-radius: @radius;
      border-bottom-right-radius: @radius;
    }
    &:hover {
      .@{prefix}-container-left,
      .@{prefix}-container-right {
        opacity: 1;
      }
    }

    li {
      position: absolute;
      width: 45%;
      height: 100%;
      opacity: 0;
      will-change: left, right, transform;
      div {
        height: 100%;
        border-radius: 8px;
      }
    }
    .@{prefix}-normal-item {
      left: 50%;
      cursor: pointer;
      transition: all @duaring;
      transform: translateX(-50%) translateZ(0);
    }
    .@{prefix}-prev,
    .@{prefix}-next {
      .show();
    }
    .@{prefix}-prev {
      left: 0;
      transform: translateX(0) translateZ(0);
      &-span {
        transition: none;
        .prevActiveFn(10%);
      }
    }
    .@{prefix}-next {
      right: 0;
      left: auto;
      transform: translateX(0) translateZ(0);
      &-span {
        transition: none;
        .nextActiveFn(10%);
      }
    }
    .@{prefix}-current {
      left: 50%;
      z-index: 1;
      transform: translateX(-50%) translateZ(0) scale(1.2);
      .show();
    }
    .@{prefix}-current-span {
      animation: spanScale @duaring cubic-bezier(0, 0, 0.05, 0.58);
    }
    .@{prefix}-span-current {
      transition: none;
    }
  }
  &-pagination {
    height: 10%;
    margin-top: 20px;
    li {
      display: inline-block;
      width: 8px;
      height: 8px;
      margin: 0 6px;
      background-color: var(--background-lighter);
      border-radius: 50%;
    }
    li&-active {
      background-color: var(--base-color);
    }
  }
}
